<?php /*a:2:{s:53:"D:\www\long_shop\app\view\customer\customer_edit.html";i:1709380918;s:42:"D:\www\long_shop\app\view\common\head.html";i:1702389678;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="/static/jquery/jquery-1.12.4.min.js"></script>    
    <link href="/static/bst5.3.2/css/bootstrap.min.css" rel="stylesheet">
    <script src="/static/bst5.3.2/js/bootstrap.bundle.min.js"></script>
    <link rel="stylesheet" href="/static/bst-icons/font/bootstrap-icons.css">
    <script src="/static/layer/layer/layer.js"></script>
    <link rel="stylesheet" href="/static/css/my.css">    
</head>
<head>
<title>顾客编辑</title>
    <link rel="stylesheet" href="/static/flatpickr/flatpickr.min.css">
    <script src="/static/flatpickr/flatpickr.js"></script>

</head>
<style>
  label{width: 18%;}
  .form-control{display:inline-block;width: 80%;}
  h2{height:50px;line-height: 30px;}
  .box{border:1px solid #ccc;padding: 20px;box-shadow: 1px 1px 4px #888;position: relative;}
</style>
<body style="">
    <div class="container p-3" style="margin-left: 10px;"  >
    
    <form method="post" action="/index.php/customer/edit" enctype="multipart/form-data">
      <input type="hidden" name="id" id="id" value="<?php echo htmlentities($data['id']); ?>" />
      <div class="row">
        <div class="col box" style="margin-right:10px;">
        <h2>基本资料，编号：<?php echo htmlentities($data['id']); ?> </h2>
        <div class="mb-3 mt-3">
          <!-- <lable for="name" class="form-label">编号:</label> -->
          <input type="hidden" class="form-control" value="<?php echo htmlentities($data['id']); ?>" placeholder="" disabled />
        </div>
        <div class="mb-3">
          <label for="title" class="form-label">顾客姓名:</label>
          <input type="text" class="form-control" id="name" name="name" value="<?php echo htmlentities($data['name']); ?>" placeholder="" />
        </div>
        <div class="mb-3">
          <label for="id_card" class="form-label">身份证号码:</label>
          <input type="text" class="form-control" id="id_card" name="id_card" value="<?php echo htmlentities($data['id_card']); ?>" placeholder="身份证号码" />
        </div>        <div class="mb-3">
          <label for="title" class="form-label">手机号码:</label>
          <input type="text" class="form-control" id="mobile" name="mobile" value="<?php echo htmlentities($data['mobile']); ?>" placeholder="" />
        </div>

        <div class="mb-3 row" >
          <label for="inviter_name" class="form-label" style="width:initial;width:115px;">邀请人:</label>
          <div class="input-group" style="width:76%;" >
            <input type="hidden" class="form-control" id="inviter" name="inviter" value="<?php echo htmlentities($data['inviter']); ?>" /></c>
            <input type="text" class="form-control" id="inviter_name" value="<?php echo htmlentities($data['inviter_name']); ?>" placeholder="姓名或者手机号码" /></c>
            <button type="button" id="find_inviter" class="btn btn-info  bi-search" >查找邀请人</button>
          </div>
        </div>                   
        <div class="mb-3">
          <label for="address" class="form-label">现居地址:</label>
          <input type="text" class="form-control" id="address" name="address" value="<?php echo htmlentities($data['address']); ?>" placeholder="现居地址" />
        </div>        

        <div class="mb-3">
          <label for="title" class="form-label">出生日期:</label>
          <input type="text" class="form-control" id="birth_date" name="birth_date" value="<?php echo htmlentities($data['birth_date']); ?>" placeholder="" />
        </div>
        <div class="mb-3">
          <label for="title" class="form-label">性别:</label>
            <input type="radio" class="form-check-input" id="radio1" name="sex" value="1" <?php if($data['sex']==1): ?>checked<?php endif; ?>  /> 
            <label class="form-check-label" for="radio1">男</label>
            <input type="radio" class="form-check-input" id="radio2" name="sex" value="2" <?php if($data['sex']==2): ?>checked<?php endif; ?> />
            <label class="form-check-label" for="radio2">女</label>
        </div>
      <div style="margin-top: 10px;position: absolute;bottom: 0px;right:10px;padding: 10px ;min-width: 95%;text-align: right;">
<!--         <button  type="button" class="btn btn-info" onclick="doSave()">上一个</button>
        <button  type="button" class="btn btn-secondary" onclick="doSave()">下一个</button> -->
      </div>

      </div>


      <div class="col box" >
        <h2>其他信息：<?php echo htmlentities($data['fee_id_name']); ?></h2>
        <div class="mb-3" style="width:70%;">
          <label for="type" class="form-label">顾客类别:</label>
            <select id="type" name="type" class="form-control">
              <?php foreach($type as $k=>$v): ?>
                <option value="<?php echo htmlentities($k); ?>" <?php if($data['type']==$k): ?> selected <?php endif; ?>><?php echo htmlentities($v); ?></option>
              <?php endforeach; ?>
            </select>

         </div>

  

        <div class="mb-3" style="width:70%;">
          <label for="" class="form-label">跟进内容:</label>
          <textarea id="follow_memo" name="follow_memo" class="form-control" style="height:60px;" placeholder="随手记" ></textarea>
        </div>   

        <div style="position: absolute;top:20px;right:20px;width:170px; padding: 5px; border:1px solid #ccc;text-align: center;">
          <img src="<?php echo htmlentities($data['image']); ?>" style="width: 140px;"/><br/>
          <input type="file"  name="file" /> <br> 
        </div>

      <div class="text-left" style="margin-top: 10px;border-top:1px solid #d7d7d7;position: absolute;bottom: 0px;left:10px;padding: 10px ;min-width: 95%;">
        <?php if($user['group_id']==1): ?>
          <button  type="button" class="btn btn-primary" onclick="doSave()">保存修改</button>
        <?php endif; ?>
      </div>
      </div>
    </div>
    </form>

    <div style="height: 10px;"></div>

    <div id="log_box">

    <div class="btn-group" role="group" aria-label="Basic radio toggle button group">
      <input type="radio" class="btn-check" name="btnradio" id="btnradio1" autocomplete="off" checked>
      <label class="btn btn-outline-info" for="btnradio1">跟进记录</label>      

      <input type="radio" class="btn-check" name="btnradio" id="btnradio2" autocomplete="off" >
      <label class="btn btn-outline-info" for="btnradio2">修改记录</label>

      <input type="radio" class="btn-check" name="btnradio" id="btnradio3" autocomplete="off">
      <label class="btn btn-outline-info" for="btnradio3">订单记录</label>

      <input type="radio" class="btn-check" name="btnradio" id="btnradio4" autocomplete="off">
      <label class="btn btn-outline-info" for="btnradio4">账单记录</label>      
    </div>

      <div >
        <table id="follow_log" class="table table-sm table-hover table-striped" >
          <thead>
          <tr>
            <th>序号</th>
            <!-- <th>学员</th> -->
            <th>跟进内容</th>
            <th>操作人</th>
            <th>日期</th>
          </tr>
          </thead>
          <tbody>

          </tbody>
        </table>

        <table id="allocate_log" class="table table-sm table-hover table-striped" style="display: none;"  >
          <thead>
          <tr>
            <th>序号</th>
            <th>部门</th>
            <th>备注</th>
            <th>操作人</th>
            <th>日期</th>
          </tr>
          </thead>
          <tbody>

          </tbody>
        </table>

        <table id="order_log" class="table table-sm table-hover table-striped" style="display: none;"  >
          <thead>
          <tr>
            <th>序号</th>
            <th>订单号</th>
            <th>订单内容</th>
            <th>订单备注</th>
            <th>订单状态</th>
            <th>日期</th>
          </tr>
          </thead>
          <tbody>

          </tbody>
        </table>

        <table id="acc_log" class="table table-sm table-hover table-striped" style="display: none;"  >
          <thead>
          <tr>
            <th>序号</th>
            <th>类别</th>
            <th>金额</th>
            <th>备注</th>
            <th>状态</th>
            <th>日期</th>
          </tr>
          </thead>
          <tbody>

          </tbody>
        </table>

      </div>

    </div>


    </div>

<script type="text/javascript">
    flatpickr("#birth_date", {});
    $(".birth_date").flatpickr({
        enableTime: true,
        dateFormat: "Y-m-d H:i:s",
    });  

    $(function(){
    
      $("#btnradio1").on('click',function(){
        $('table').hide();
        $.post('/log/log',{table:'follow_log',customer_id:$("#id").val()},function(res){
          //console.log(res);
          $("#follow_log tbody").empty();
          for(var i=0;i<res.length;i++){
            var tr="<tr>";
            tr+="<td>"+(i+1)+"</td>";
            //tr+="<td>"+res[i].customer_id_name+"</td>";
            tr+="<td>"+res[i].memo+"</td>";
            tr+="<td>"+res[i].user_id_name+"</td>";
            tr+="<td>"+res[i].create_time+"</td>";
            tr+="</tr>";

            //console.log(tr);
            $("#follow_log tbody").append(tr);
            
          }

          $("#follow_log").show();
        });
      })

      $("#btnradio1").trigger('click');

      $("#btnradio2").on('click',function(){
        $('table').hide();
        $.post('/log/log',{table:'allocate_log',customer_id:$("#id").val()},function(res){
          //console.log(res);
          $("#allocate_log tbody").empty();
          for(var i=0;i<res.length;i++){
            var tr="<tr>";
            tr+="<td>"+(i+1)+"</td>";
            tr+="<td>"+res[i].dept_id_name+"</td>";
            tr+="<td>"+res[i].memo+"</td>";
            tr+="<td>"+res[i].user_id_name+"</td>";
            tr+="<td>"+res[i].create_time+"</td>";
            tr+="</tr>";

            //console.log(tr);
            $("#allocate_log tbody").append(tr);
            $("#allocate_log").show();
          }

        });

      })
      $("#btnradio3").on('click',function(){
        var cid=$("#id").val();
        $('table').hide();

        $.post('/log/order_list',{customer_id:cid,log:1},function(res){
          //console.log(res);

          $("#order_log tbody").empty();
          for(var i=0;i<res.length;i++){
            var tr="<tr>";
            tr+="<td>"+(i+1)+"</td>";
            tr+="<td>"+res[i].order_no+"</td>";
            tr+="<td>"+res[i].goods_list+"</td>";
            tr+="<td>"+res[i].memo+"</td>";                        
            tr+="<td>"+res[i].status_name+"</td>";                        
            tr+="<td>"+res[i].create_time+"</td>";
            tr+="</tr>";

            //console.log(tr);
            $("#order_log tbody").append(tr);
            $("#order_log").show();
          }


        });
      })


      $("#btnradio4").on('click',function(){
        $('table').hide();
        var cid=$("#id").val();
        $.post('/log/acc_log',{customer_id:cid},function(res){
          console.log(res);

          $("#acc_log tbody").empty();
          for(var i=0;i<res.length;i++){
            var tr="<tr>";
            tr+="<td>"+(i+1)+"</td>";
            tr+="<td>"+res[i].type_name+"</td>";
            tr+="<td>"+res[i].money+"</td>";
            tr+="<td>"+res[i].memo+"</td>";                        
            tr+="<td>"+res[i].status_name+"</td>";                        
            tr+="<td>"+res[i].create_time+"</td>";
            tr+="</tr>";

            //console.log(tr);
            $("#acc_log tbody").append(tr);
            $("#acc_log").show();
          }

        });
      })                  


      $("#find_inviter").on('click',function(){
        if(!$("#inviter_name").val()) {
          $("#inviter").val('');
          layer.msg('请输入姓名或者手机设置邀请人,清空内容可以删除邀请人！');return;
        }
        $.post('/index.php/customer/getOne',{nameOrMobile:$("#inviter_name").val()},function(res){
          if(res.code){
            var data = res.data;
            console.log(data.id+","+$("#id").val());
            if(data.id==$("#id").val()){
              $("#inviter").val('');
              layer.msg("太离谱了吧，自己邀请自己!");
            }else if(data.inviter==$("#id").val()){
              $("#inviter").val('');
              layer.msg("太离谱了吧，互相邀请对方是不对的哦!");
            }else{
              var inviter = data.id;
              $("#inviter").val(inviter);
              layer.msg(res.msg);
            }
          }else{
            layer.msg(res.msg);
          }

        })
      })

    })

    function doSave(){
      if(!$("#name").val()) {
        layer.msg("无效的名称(Invalid name)!");
        return 0;
      }    
      if(!$("#mobile").val()) {
        layer.msg("无效的电话(Invalid mobile)!");
        return 0;
      }


      //询问框
      layer.confirm('是否确定保存?', {
        btn: ['是的','取消'] //按钮
      }, function(){
        $('form').submit();
      }, function(){
        layer.msg("Cancel!");
        return 0;
      });
    }

</script>


</body>
</html>
